# -*- coding: utf-8 -*-
from SStack import *
import time


def fact(n):
    if n == 0:
        print("I am here " + str(n))
        return 1
    else:
        ret = n * fact(n - 1)
        #print(n, ret)
        return ret


def norec_fact(n):
    res = 1
    st = SStack()
    while n > 0:
        st.push(n)
        n -= 1
    while not st.is_empty():
        x = st.pop()
        res *= x
        #print(x, res)
    return res


if __name__ == '__main__':
    start = time.clock()
    ret = fact(100)
    end = time.clock()
    print(ret)
    print(end - start)
    start = time.clock()
    ret1 = norec_fact(100)
    end = time.clock()
    print(ret1)
    print(end - start)
